USE [GradingSystemDb]

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Schedules] (
	[ScheduleId] [int] IDENTITY(1,1) NOT NULL,
	[EmployeeId] [int] NOT NULL,
	[SubjectId] [int] NOT NULL,
	[RoomNumber] [nvarchar](max) NOT NULL,
	[ScheduleDay] [nvarchar](max) NOT NULL,
	[StartTime] [datetime] NOT NULL,
	[EndTime] [datetime] NOT NULL,
	[StartDate] [datetime] NOT NULL,
	[EndDate] [datetime] NOT NULL,
	[Semester] [nvarchar](max) NOT NULL,
	[CreatedBy] [int] NOT NULL,
	[CreatedDttm] [datetime] NOT NULL,
	[ModifiedBy] [int] NOT NULL,
	[ModifiedDttm] [datetime] NOT NULL,
	CONSTRAINT [PK_Schedules] PRIMARY KEY CLUSTERED (
		[ScheduleId] ASC
	)
	WITH (
		PAD_INDEX=OFF, 
		STATISTICS_NORECOMPUTE=OFF, 
		IGNORE_DUP_KEY=OFF, 
		ALLOW_ROW_LOCKS=ON, 
		ALLOW_PAGE_LOCKS=ON
	) 
	ON [PRIMARY]
) 
ON [PRIMARY]

GO
ALTER TABLE	[dbo].[Schedules] WITH CHECK ADD CONSTRAINT [FK_Employees_EmployeeId_Schedules_EmployeeId] FOREIGN KEY([EmployeeId])
REFERENCES  [dbo].[Employees] ([EmployeeId])
GO
ALTER TABLE [dbo].[Schedules] CHECK CONSTRAINT [FK_Employees_EmployeeId_Schedules_EmployeeId]
GO
ALTER TABLE [dbo].[Schedules]  WITH CHECK ADD  CONSTRAINT [FK_Subjects_SubjectId_Schedules_SubjectId] FOREIGN KEY([SubjectId])
REFERENCES  [dbo].[Subjects] ([SubjectId])
GO
ALTER TABLE [dbo].[Schedules] CHECK CONSTRAINT [FK_Subjects_SubjectId_Schedules_SubjectId]

